package com.ming.dao;

import com.ming.po.Cart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CartDao {

	@Insert("INSERT INTO cart(foodId,businessId,userId,quantity) VALUES (#{foodId},#{businessId},#{userId},#{quantity})")
	int saveCart(Cart cart);
	@Update("UPDATE cart SET quantity = #{quantity} WHERE userId = #{userId} AND businessId = #{businessId} AND foodId = #{foodId}")
	int updateCart(Cart cart);
	// @Delete("DELETE FROM cart WHERE userId = #{userId} AND businessId = #{businessId} AND foodId = #{foodId}")
	int removeCart(Cart cart);

	// @Select("SELECT * FROM cart WHERE businessId=#{businessId} AND userId=#{userId}")
	List<Cart> listCart(Cart cart);
}
